package com.ds.infra.ibatis.demo.mapper;

import com.ds.infra.ibatis.annotation.Insert;
import com.ds.infra.ibatis.annotation.Param;
import com.ds.infra.ibatis.annotation.Select;
import com.ds.infra.ibatis.annotation.Update;
import com.ds.infra.ibatis.demo.model.Account;

/**
 * 作用： 账户Mapper接口，用于数据库操作
 *
 * @author WeiShaoying
 */
public interface AccountMapper {

    @Select("SELECT * FROM account WHERE id = #{id}")
    Account selectById(@Param("id") Long id);

    @Update("UPDATE account SET balance = #{balance} WHERE id = #{id}")
    int updateBalance(@Param("id") Long id, @Param("balance") Double balance);

    @Insert("INSERT INTO account(account_number, balance) VALUES(#{accountNumber}, #{balance})")
    int insert(Account account);
}
